package com.lorianknights.rpg.screens
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.utils.getDefinitionByName;
	import com.lorianknights.rpg.core.Player;
	import com.lorianknights.rpg.screens.skins.ScreenCharacterPanelSelectionSkin;
	import com.lorianknights.rpg.screens.Screen;
	
	public class ScreenCharacterPanelSelection extends Screen
	{
		
		private var skin:ScreenCharacterPanelSelectionSkin;
		private var player:Player;
		
		public function ScreenCharacterPanelSelection()
		{
			
			super();
			
		}
		
		public override function init():void
		{
			
			var assetClass:Class = null;
			
			this.skin = new ScreenCharacterPanelSelectionSkin();
			addChild(this.skin);
			
				if (this.skin == null)
				{
					
					assetClass = getDefinitionByName(Constants.CHARACTER_SELECTION_SKIN) as Class;
					this.skin.txtWins = this.skin.getChildByName(Constants.TXT_WINS_STR) as TextField;
					this.skin.txtName = this.skin.getChildByName(Constants.TXT_STR_NAME) as TextField;
					this.skin.txtLevel = this.skin.getChildByName(Constants.TXT_LVL_STR) as TextField;
					this.skin.txtLosses = this.skin.getChildByName(Constants.TXT_LOSSES_STR) as TextField;
					this.skin.txtDex = this.skin.getChildByName(Constants.TXT_DEX_STR) as TextField;
					this.skin.txtAur = this.skin.getChildByName(Constants.TXT_AUR_STR) as TextField;
					this.skin.txtCha = this.skin.getChildByname(Constants.TXT_CHA_STR) as TextField;
					this.skin.txtFor = this.skin.getChildByName(Constants.TXT_FOR_STR) as TextField;
					this.skin.txtPot = this.skin.getChildByName(Constants.TXT_POT_STR) as TextField;
					this.skin.txtConst = this.skin.getChildByName(Constants.TXT_CONST_STR) as TextField;
					this.skin = addChildAt(new assetClass(), 0) as MovieClip;
					
					if (this.skin.numChildren > 0)
					{
						
						addChild(this.skin);
						
					}
				}
				
				this.skin.txtWins.text = this.player.charData.intWins.toString();
				this.skin.txtName.text = this.player.charData.strUsername;
				this.skin.txtLevel.text = this.player.charData.intLevel.toString();
				this.skin.txtLosses.text = this.player.charData.intLosses.toString();
				this.skin.txtDex.text = this.player.charData.intDEX.toString();
				this.skin.txtAur.text = this.player.charData.intAUR.toString();
				this.skin.txtCha.text = this.player.charData.intChA.toString();
				this.skin.txtWis.text = this.player.charData.intWIS.toString();
				this.skin.txtFor.text = this.player.charData.intFOR.toString();
				this.skin.txtPot.text =  this.player.charData.intPOT.toString();	
				this.skin.txtConst.text = this.player.charData.intCONST.toString();
				this.skin.strAlliance.text = this.player.charData.strAlliance;
				
		}
			
	}
}
			
					
				
				